package sanrenxing.dayEnd.backRepertoryTotal.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import sanrenxing.dayEnd.backRepertoryTotal.domain.Statisical;
import sanrenxing.dayEnd.backRepertoryTotal.service.StatisicalBiz;
import sanrenxing.dayEnd.backRepertoryTotal.service.TransactionService;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 功能:
 * 编写者：
 * 日期：2021
 * 版本：1.0
 */
@RequestMapping("/Statisical")
@RestController
public class StatisicalController {
    @Autowired
    private StatisicalBiz statisicalBiz;
    //自动装配  业务处理方法 改
    @Autowired
    private TransactionService transactionService;

    @GetMapping("/stat")
    public Map<String, Object> addStatisical(HttpServletRequest req, int page, int limit) {
        //定义多条件查询对象
        Statisical statisical = new Statisical();
        //接收请求中的交易日期
        String tranDate = req.getParameter("tranDate");
        //判断是否加入
        if (tranDate != null && tranDate.trim().length() != 0) {
            statisical.setTranDate(tranDate);
        }

        //调用业务层多条件查询方法
        String condition = statisicalBiz.getCount(statisical);
        //执行多条件查询语句
        List<Statisical> statisicals = statisicalBiz.findByPages(limit, page, condition);
        //获取总记录行数
        int totalRows = statisicalBiz.count(condition);

        Map<String, Object> map = new HashMap<>();
        map.put("code", 0);
        //证券信息 改
        map.put("securi",transactionService.SecuritiesInfomationLXF());
        map.put("msg", "");
        map.put("data", statisicals);
        map.put("count", totalRows);

        return map;
    }

}
